(function () {
  if ("object" != typeof ue || "object" != typeof ue.interface) {
    // 初始化 ue 和 ue.interface
    if ("object" != typeof ue) {
      ue = {};
    }
    if ("object" != typeof ue.interface) {
      ue.interface = {};
    }

    // 定义 ue.interface.broadcast 方法
    ue.interface.broadcast = function (e, t) {
      if ("string" == typeof e) {
        var o = [e, ""];
        if (t !== undefined) {
          o[1] = t;
        }
        var n = encodeURIComponent(JSON.stringify(o));
        if (typeof history === "object" && typeof history.pushState === "function") {
          history.pushState({}, "", "#" + n);
          history.pushState({}, "", "#" + encodeURIComponent("[]"));
        } else {
          document.location.hash = n;
          document.location.hash = encodeURIComponent("[]");
        }
      }
    };
  } else {
    // 如果 ue 和 ue.interface 已经存在，直接使用它
    (function (e) {
      e.interface = {};
      e.interface.broadcast = function (t, o) {
        if ("string" == typeof t) {
          if (o !== undefined) {
            e.broadcast(t, JSON.stringify(o));
          } else {
            e.broadcast(t, "");
          }
        }
      };
    })(ue.interface);
  }

  // 将 ue.interface.broadcast 绑定到 window.ue5
  window.ue = ue;
  window.ue5 = ue.interface.broadcast;
})();
